package com.jt.web;

import com.fasterxml.jackson.databind.util.JSONPObject;
import com.jt.pojo.ItemDesc;
import com.jt.util.ObjectMapperUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class JSONPController {

    /**
     * 请求网址：http://manage.jt.com/web/testJSONP
     */

    @RequestMapping("/web/testJSONP")
    public JSONPObject json(String callback){
        ItemDesc itemDesc = new ItemDesc();
        itemDesc.setItemId(30L).setItemDesc("测试JsonP22");
        return new JSONPObject(callback,itemDesc);
    }

//    @RequestMapping("/web/testJSONP")
//    public String json(String callback){
//        ItemDesc itemDesc = new ItemDesc();
//        itemDesc.setItemId(30L).setItemDesc("测试JsonP");
//        String json = ObjectMapperUtil.toJSON(itemDesc);
//        return callback+"("+json+")";
//    }
}
